package mobi.weq.util.edinburgh;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;

import mobi.weq.dao.SensorObservationDao;
import mobi.weq.model.SensorObservation;
import mobi.weq.util.Util;

public class EdinburghDataGenerator {
	// double k = 407, j = 413;
	// double j = 64, k = 43;

	// lat diff:0.07344955795602459
	// lng diff :0.54931640625
	public static void generateData(int days) throws SQLException {
		
		// double increment = 1.0 / EdinburghMap.GRID_DENSITY;
		// System.out.println(EdinburghMap.LAT2 + increment / 10);
		long t = new Date().getTime();
		Date d = new Date();
		d.setMinutes(0);
		d.setSeconds(0);
//		d = Util.decreaseDateByDay(d, -90);
		
		for (int i = 0; i < days; i++) {
			ArrayList<SensorObservation> o = EdinburghGeneratorUtil.generateEdinburghSensorHourlyObservationsThroughoutCityEveryGrid(d);
			System.out.println(d + "#" + o.size());
			SensorObservationDao dao = new SensorObservationDao();
			dao.addObservations(o);
			d = Util.decreaseDateByDay(d, 1);
			System.out.println("Time in Seconds: " + (new Date().getTime()  - t)/ 1000);
		}
	}

	public static void main(String[] args) {
		try {
			generateData(90);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
